Consulting Programs

Instead of compiling a file to generate a byte code file which then has to be loaded, a program may be executed interpretively by ``consulting'' the corresponding source file: consult/1 (L) consult/2 (L)

| ?- consult(SourceFile [, OptionList ] ).
or
| ?- consult(SourceFile, OptionList, PredList).
where SourceFile is a Prolog atom which is the name of a file containing a Prolog source program; OptionList is a list of options to consult; and PredList is a list of terms P/N, where P is a predicate name and N its arity, specifying which predicates have been consulted from SourceFile; its principal use is for setting trace points on the predicates in the file (see Section [*]). Notice that PredList can only appear in consult/3.

At this point, the options recognized for consult are the following:

t
``trace''. Causes a trace point to be set on any predicate in the current file that does not already have a trace point set.
v
``verbose''. Causes information regarding which predicates have been consulted to be printed out. Default: off.

In addition to the above, options for the macro expander are also recognized (see Section [*])).

consult will create an index on the principal functor of the first argument of the predicates being consulted, unless this is changed using the index/3 directive. In particular, note that if no index is desired on a predicate foo/n, then the directive

:- index(foo, n, 0).
should be given.

It is important to note that SB-Prolog's consult predicate is similar to that of Quintus Prolog, and behaves like C-Prolog's reconsult. This means that if a predicate is defined across two or more files, consulting them will result in only the clauses in the file consulted last being used.